package com.mask.share.life.jk.hander;

import com.mask.share.life.jk.ExtInfo;
import org.apache.commons.collections4.queue.CircularFifoQueue;
import org.opencv.core.Mat;

public interface ImageHandler {

    ExtInfo handle(CircularFifoQueue<Mat> imageBuffer, CircularFifoQueue<Mat> dealImageBuffer);


    default Mat getCurrentImage(CircularFifoQueue<Mat> imageBuffer) {
        int size = imageBuffer.size();
        return imageBuffer.get(size - 1);
    }

    default Mat getBeforeImage(CircularFifoQueue<Mat> imageBuffer, int before) {
        int size = imageBuffer.size();
        int maybeIndex = size - before;
        if (maybeIndex < 0) {
            return null;
        } else {
            return imageBuffer.get(maybeIndex);
        }
    }
}
